package com.example.routeplansystem.controller;

import com.example.routeplansystem.anotation.UserPermissionConf;
import com.example.routeplansystem.constant.PageRes;
import com.example.routeplansystem.entity.dto.ResponseEntity;
import com.example.routeplansystem.entity.po.NodePojo;
import com.example.routeplansystem.entity.po.Program;
import com.example.routeplansystem.entity.vo.ProgramRes;
import com.example.routeplansystem.service.ProgramService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author lucong
 * @Date 2022/10/31
 * @Description
 */
@RestController
@RequestMapping("program")
@Api(tags = "自定义算法模块")
@Slf4j
@UserPermissionConf
public class ProgramController {

    @Autowired
    private ProgramService programService;


    @GetMapping
    public ResponseEntity<ProgramRes> getProgram(@RequestParam Integer id) {
        return new ResponseEntity<>(programService.getProgramById(id));
    }

    @GetMapping("page")
    public ResponseEntity<PageRes<Program>> pageProgram(@RequestAttribute("userId") Integer userId,
                                                        @RequestParam Integer pageNum,
                                                        @RequestParam Integer pageSize) {
        PageRes<Program> page = programService.pageProgramByUserId(userId, pageNum, pageSize);
        return new ResponseEntity<>(page);
    }



}
